#!/bin/sh

# This shell script used to build the rootfs for max2440
# It need use the "root" priviledge to excute.

ROOTFS_PATH=`pwd`
APPS_PATH=${ROOTFS_PATH}/apps
user=`whoami`
#:<<BLOCK
if [ $user != root ]; then
        echo "This script must excute as root priviledge, please use \"sudo\" to excute."
        exit;
fi

if [ ! -d mnt -o -f ramdisk.gz ]; then
        mkdir -p mnt && gzip -d ramdisk.gz && mount -o loop ramdisk mnt
fi
#BLOCK


# Cross compile the application
cd ${APPS_PATH}

for i in `ls ${APPS_PATH}`; do
        if [ -f $i/build.sh ] ; then
                cd $i
                sh build.sh
                cd -
        fi
done


